#include<bits/stdc++.h>
using namespace std;
int n,L,R;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>L>>R;
	int l=(L+n)%n,r=(R+n)%n;
	if(r<=l){
		cout<<n-1;
		return 0;
	}
	cout<<r;
	return 0;
}
